package com.summer.campussct.controller;


import com.summer.campussct.pojo.dto.RestResult;
import com.summer.campussct.service.ICategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 分类表 前端控制器
 * </p>
 *
 * @author Mr.Chen
 * @since 2024-04-21
 */
@RestController
@Api("分类API接口")
@RequestMapping("/category")
public class CategoryController {

    @Resource
    private ICategoryService categoryService;

    @ApiOperation("获取首页分类数据，封装成map返回")
    @GetMapping("home")
    public RestResult getHomeCategory(){
       return categoryService.home();
    }

    @ApiOperation("获取list页分类数据，封装成map返回，用于条件筛选，参数为0表示查询所有品牌")
    @GetMapping("list/{categoryId}")
    public RestResult getConditionCategory(
            @PathVariable(value = "categoryId") Integer categoryId ){
        return categoryService.listPage(categoryId);
    }

    @ApiOperation("获取list页品牌列表，封装成map返回，用于条件筛选")
    @GetMapping("brand/{categoryId}")
    public RestResult getBrandList(@PathVariable("categoryId") int categoryId){
        return categoryService.brandList(categoryId);
    }

    @ApiOperation("获取车辆分类列表，用于下拉菜单")
    @GetMapping("vehicleCategoryList")
    public RestResult getVehicleCategoryList(){
        return categoryService.getVehicleCategoryList();
    }

    @ApiOperation("根据id获取分类名")
    @GetMapping("categoryName/{id}")
    public RestResult getCategoryName(@PathVariable("id") long id){
        return categoryService.getCategoryName(id);
    }
}

